import { Select } from 'antd';
const Option = Select.Option;
export default {
  getOptionList(data, hasAll = true) {
    if (!data) {
      return []
    }
    let option = [];
    if(hasAll){
      option.push(<Option value="" key="">全部</Option>)
    }
    data.map((item) => {
      option.push(<Option value={item.id} key={item.id}>{item.name}</Option>)
    });
    return option;
  },
  pageination(data, callback, pageSizeChange) {
    let page = {
      onChange: (current) => {
        callback(current)
      },
      current: data.page,
      pageSize: data.pageSize,
      total: data.total,
      showTotal: () => {
        return `共${data.total}条`
      },
      showQuickJumper: false,
      defaultPageSize: 10,
      pageSizeOptions: ['10', '20', '50', '100'],
      showSizeChanger: true,
      onShowSizeChange: (current, pageSize) => {
        pageSizeChange(current, pageSize)
      },
    }
    return page;
  },
} 